package com.hmtech.aup.presentation.auth

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.hmtech.aup.domain.vo.UserVO
import com.hmtech.aup.network.RetrofitClient
import kotlinx.coroutines.launch

// 使用场景
class UserViewModel : ViewModel() {
    private val _userVOLiveData = MutableLiveData<UserVO>()
    val userVOLiveData: LiveData<UserVO> = _userVOLiveData

    fun fetchUser(userId: Int) {
        viewModelScope.launch {
            try {
                val user = RetrofitClient.userApiService.getUserInfo()
                _userVOLiveData.value = user
            } catch (e: Exception) {
                Log.e("Network", "Error: ${e.message}")
            }
        }
    }
}